package com.yjj.demo.common.utils;

/**
 * 数字相关工具
 *
 * @author yangjiajia
 * @createdAt 2023/2/21 14:21
 */
public class MathUtil {

    /**
     * 将a和b合并成一个可以拆分的数字
     * @param a
     * @param b
     * @date 2023/2/21 14:14
     * @return long
     **/
    public static long mergeNum(int a, int b) {
        return ((long)a << 32) | ((long)b & 0xFFFFFFFFL);
    }

    public static int splitFirst(long num) {
        return (int)(num >> 32);
    }

    public static int splitSecond(long num) {
        int d = (int)(num & 0xFFFFFFFFL);
        if (d < 0) {
            d |= 0xFFFFFFFF00000000L;
        }
        return d;
    }





}
